  // LEAK GLOBAL OPTIONS
    $.validationEngine = {
        fieldIdCounter: 0,
        defaults: {

            // Name of the event triggering field validation
            validationEventTrigger: "blur",

            // Automatically scroll viewport to the first error
            scroll: false,
            // Focus on the first input
            focusFirstField: true,
            // Opening box position, possible locations are: topLeft,
            // topRight, bottomLeft, centerRight, bottomRight
            promptPosition: "topLeft",
            inlineValidation: false,
            bindMethod: "bind",
            // internal, automatically set to true when it parse a _ajax rule
            inlineAjax: false,
            // if set to true, the form data is sent asynchronously via ajax to the form.action url (get)
            ajaxFormValidation: false,
            // The url to send the submit ajax validation (default to action)
            ajaxFormValidationURL: false,
            // HTTP method used for ajax validation
            ajaxFormValidationMethod: 'get',
            // Ajax form validation callback method: boolean onComplete(form, status, errors, options)
            // retuns false if the form.submit event needs to be canceled.
            onAjaxFormComplete: $.noop,
            // called right before the ajax call, may return false to cancel
            onBeforeAjaxFormValidation: $.noop,
            // Stops form from submitting and execute function assiciated with it
            onValidationComplete: false,
            // Used when you have a form fields too close and the errors messages are on top of other disturbing viewing messages
            doNotShowAllErrosOnSubmit: false,
            // Object where you store custom messages to override the default error messages
            custom_error_messages: {},
            // true if you want to vind the input fields
            binded: true,
            // set to true, when the prompt arrow needs to be displayed
            showArrow: true,
            // did one of the validation fail ? kept global to stop further ajax validations
            isError: false,
            // Limit how many displayed errors a field can have
            maxErrorsPerField: false,
            // Caches field validation status, typically only bad status are created.
            // the array is used during ajax form validation to detect issues early and prevent an expensive submit
            ajaxValidCache: {},
            // Auto update prompt position after window resize
            autoPositionUpdate: false,
            InvalidFields: [],
            onFieldSuccess: false,
            onFieldFailure: false,
            onSuccess: false,
            onFailure: false,
            addSuccessCssClassToField: false,
            addFailureCssClassToField: false,
            // Auto-hide prompt
            autoHidePrompt: true,
            // Delay before auto-hide
            autoHideDelay: 3000,
            // Fade out duration while hiding the validations
            fadeDuration: 0.3,
            // Use Prettify select library
            prettySelect: false,
            // Add css class on prompt
            addPromptClass: "formError-small",
            // Custom ID uses prefix
            usePrefix: "",
            // Custom ID uses suffix
            useSuffix: "",
            // Only show one message per error prompt
            showOneMessage: true,
            //只提交一次，不会重复提交
            oneSubmitNum: true
        }
    };
    $(function() {
        $.validationEngine.defaults.promptPosition = methods.isRTL() ? 'topRight': "topLeft"
    });
})(jQuery); (function($) {
    $.fn.validationEngineLanguage = function() {};
    var hostname = location.hostname;
    var hostport = "80";
    if ('42.96.190.4' == hostname) {
        hostport = '8081';
    }
    //var ajaxurl = 'http://' +  hostname +':' + hostport + '/account/';
    var maindomain;
    if (window.location.protocol == 'https:') {
        maindomain = 'www'
    } else {
        maindomain = 'dev.demo'
    }
    //var ajaxurl = window.location.protocol + '//' + maindomain + '.huobi.com/account/';
    if (window.location.href.indexOf("www.huobi.com") > -1) {
        ajaxurl = "https://www.huobi.com/account/";
    } else {
        ajaxurl = "http://dev.demo.huobi.com/account/";
    }
    $.validationEngineLanguage = {
        newLang: function() {
            $.validationEngineLanguage.allRules = {
                "required": { // Add your regex rules here, you can take telephone as an example
                    "regex": "none",
                    "alertText": "* 此处不可空白",
                    "alertTextCheckboxMultiple": "* 请选择一个项目",
                    "alertTextCheckboxe": "* 您必须钩选此栏",
                    "alertTextDateRange": "* 日期范围不可空白"
                },
                "dateRange": {
                    "regex": "none",
                    "alertText": "* 无效的 ",
                    "alertText2": " 日期范围"
                },
                "dateTimeRange": {
                    "regex": "none",
                    "alertText": "* 无效的 ",
                    "alertText2": " 时间范围"
                },
                "minSize": {
                    "regex": "none",
                    "alertText": "* 最少 ",
                    "alertText2": " 个字符"
                },
                "maxSize": {
                    "regex": "none",
                    "alertText": "* 最多 ",
                    "alertText2": " 个字符"
                },
                "groupRequired": {
                    "regex": "none",
                    "alertText": "* 你必需选填其中一个栏位"
                },
                "min": {
                    "regex": "none",
                    "alertText": "* 最小值为"
                },
                "max": {
                    "regex": "none",
                    "alertText": "* 最大值为 "
                },
                "past": {
                    "regex": "none",
                    "alertText": "* 日期必需早于 "
                },
                "future": {
                    "regex": "none",
                    "alertText": "* 日期必需晚于 "
                },
                "maxCheckbox": {
                    "regex": "none",
                    "alertText": "* 最多选取 ",
                    "alertText2": " 个项目"
                },
                "minCheckbox": {
                    "regex": "none",
                    "alertText": "* 请选择 ",
                    "alertText2": " 个项目"
                },
                "equals": {
                    "regex": "none",
                    "alertText": "* 请输入与上面相同的密码"
                },
                "phone": {
                    // credit: jquery.h5validate.js / orefalo
                    "regex": /^([\+][0-9]{1,3}[ \.\-])?([\(]{1}[0-9]{2,6}[\)])?([0-9 \.\-\/]{3,20})((x|ext|extension)[ ]?[0-9]{1,4})?$/,
                    "alertText": "* 无效的电话号码"
                },
                "email": {
                    //remove $
                    // Shamelessly lifted from Scott Gonzalez via the Bassistance Validation plugin http://projects.scottsplayground.com/email_address_validation/
                    "regex": /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?/i,
                    "alertText": "* 邮件地址无效"
                },
                "integer": {
                    "regex": /^[\-\+]?\d+$/,
                    "alertText": "* 不是有效的整数"
                },
                "block_integer": {
                    "regex": /^\d+(00)$/,
                    "alertText": "* 不是有效的比特币数量"
                },
                "number": {
                    // Number, including positive, negative, and floating decimal. credit: orefalo
                    "regex": /^[\-\+]?(([0-9]+)([\.,]([0-9]+))?|([\.,]([0-9]+))?)$/,
                    "alertText": "* 无效的数字"
                },
                "date": {
                    "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/,
                    "alertText": "* 无效的日期，格式必需为 YYYY-MM-DD"
                },
                "time": {
                    "regex": /^([[0-1][0-9]|2[0-3]]):([0-5][0-9]):([0-5][0-9])$/,
                    "alertText": "* 无效的时间，格式必需为 HH:mm:ss"
                },
                "ipv4": {
                    "regex": /^((([01]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))[.]){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))$/,
                    "alertText": "* 无效的 IP 地址"
                },
                "url": {
                    "regex": /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,
                    "alertText": "* Invalid URL"
                },
                "onlyNumberSp": {
                    "regex": /^[0-9\ ]+$/,
                    "alertText": "* 只能填数字"
                },
                "loanRmbSp": {
                    "regex": /^(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,2})?$/,
                    "alertText": "* 请输入请正确的金额"
                },
                "loanBtcSp": {
                    "regex": /^(([1-9]{1}\d*)|([0]{1}))(\.(\d){1,4})?$/,
                    "alertText": "* 请输入请正确数量的比特币"
                },
                "btcAddress": {
                    "regex": /^[1|3][a-zA-Z1-9]{26,33}$/,
                    "alertText": "* 请输入正确的比特币地址"
                },
                "onlyLetterSp": {
                    "regex": /^[a-zA-Z\ \']+$/,
                    "alertText": "* 只接受英文字母大小写"
                },
                "onlyLetterNumber": {
                    "regex": /^[0-9a-zA-Z]+$/,
                    "alertText": "* 不接受特殊字符"
                },
                "notOnlyNumberOrLetter": {
                    "regex": /^\w*(([a-z][0-9])|([0-9][a-z]))[`~!@#$%^&*()_+-=]*\w*$/i,
                    "alertText": " * 请输入符合要求的密码"
                },
                "illegal": {
                    "regex": /[^-+=|,0-9a-zA-Z!@#$%^&*?_.~+\/\\(){}\[\]<>]/g,
                    "alertText": "* 不能包含非法字符"
                },
                "allNumber": {
                    "regex": /^\d+$/,
                    "alertText": "* 不能是纯数字"
                },
                "allLetter": {
                    "regex": /^[a-zA-Z]+$/,
                    "alertText": "* 不能是纯字母"
                },
                "allCharacter": {
                    "regex": /^[-+=|,!@#$%^&*?_.~+\/\\(){}\[\]<>]+$/,
                    "alertText": "* 不能是纯符号"
                },
                "allSame": {
                    "regex": /^([\s\S])\1*$/,
                    "alertText": "* 不能为同一字符"
                },
                // --- CUSTOM RULES -- Those are specific to the demos, they can be removed or changed to your likings
                "ajaxUserCall": {
                    "url": "ajaxValidateFieldUser",
                    // you may want to pass extra data on the ajax call
                    "extraData": "name=eric",
                    "alertText": "* 此名称已被其他人使用"
                    //"alertTextLoad": "* 正在确认名称是否有其他人使用，请稍等。"
                },
                "ajax_check_email": {
                    "url": ajaxurl + "ajax.php?m=check_email",
                    // you may want to pass extra data on the ajax call
                    //"extraData": "name=eric",
                    // if you provide an "alertTextOk", it will show as a green prompt when the field validates
                    //"alertTextOk": "* 此帐号名称可以使用",
                    "alertText": "* 此帐号不可用"
                    //"alertTextLoad": "* 正在确认帐号名称是否有其他人使用，请稍等。"
                },
                "ajax_check_email_exist": {
                    "url": ajaxurl + "ajax.php?m=check_email_exist",
                    // you may want to pass extra data on the ajax call
                    //"extraData": "name=eric",
                    // if you provide an "alertTextOk", it will show as a green prompt when the field validates
                    //"alertTextOk": "* 输入正确",
                    "alertText": "* 该邮箱未注册"
                    //"alertTextLoad": "* 正在确认帐号是否存在，请稍等……"
                },
                "ajax_check_invite_exist": {
                    "url": ajaxurl + "ajax.php?m=check_invite_exist",
                    // you may want to pass extra data on the ajax call
                    //"extraData": "name=eric",
                    // if you provide an "alertTextOk", it will show as a green prompt when the field validates
                    //"alertTextOk": "* 输入正确",
                    "alertText": "* 该用户不存在"
                    //"alertTextLoad": "* 正在确认帐号是否存在，请稍等……"
                },
                "ajax_check_vcode": {
                    "url": ajaxurl + "ajax.php?m=check_vcode&jsoncallback=?",
                    // you may want to pass extra data on the ajax call
                    //"extraData": "name=eric",
                    // if you provide an "alertTextOk", it will show as a green prompt when the field validates
                    //"alertTextOk": "* 验证OK",
                    "alertText": "* 此验证码不可用"
                    //"alertTextLoad": "* 正在验证，请稍等。"
                },
                'ajax_check_google_code': {
                    'url': ajaxurl + 'ajax.php?m=check_google_code&jsoncallback=?',
                    'alertText': '* 双重验证密码错误'
                },
                "ajax_check_phone": {
                    "url": ajaxurl + "ajax.php?m=check_phone",
                    // you may want to pass extra data on the ajax call
                    //"extraData": "name=eric",
                    // if you provide an "alertTextOk", it will show as a green prompt when the field validates
                    //"alertTextOk": "* 手机号码OK",
                    "alertText": "* 此手机号不可用"
                    //"alertTextLoad": "* 正在验证，请稍等。"
                },
                "ajax_check_bind_phone": {
                    "url": ajaxurl + "ajax.php?m=check_bind_phone",
                    // you may want to pass extra data on the ajax call
                    //"extraData": "name=eric",
                    // if you provide an "alertTextOk", it will show as a green prompt when the field validates
                    //"alertTextOk": "* 手机号码OK",
                    "alertText": "* 此手机号不可用"
                    //"alertTextLoad": "* 正在验证，请稍等。"
                },

                "ajax_check_sms": {
                    "url": ajaxurl + "ajax.php?m=check_sms",
                    // you may want to pass extra data on the ajax call
                    //"extraData": "name=eric",
                    // if you provide an "alertTextOk", it will show as a green prompt when the field validates
                    //"alertTextOk": "* 验证OK",
                    "alertText": "* 此验证不可用"
                    //"alertTextLoad": "* 正在验证，请稍等。"
                },

                //两个验证码的情况
                "ajax_check_sms_0": {
                    "url": ajaxurl + "ajax.php?m=check_sms",
                    // you may want to pass extra data on the ajax call
                    "extraData": "id=0",
                    // if you provide an "alertTextOk", it will show as a green prompt when the field validates
                    //"alertTextOk": "* 验证OK",
                    "alertText": "* 此验证码不可用"
                    //"alertTextLoad": "* 正在验证，请稍等。"
                },
                "ajax_check_sms_1": {
                    "url": ajaxurl + "ajax.php?m=check_sms",
                    // you may want to pass extra data on the ajax call
                    "extraData": "id=1",
                    // if you provide an "alertTextOk", it will show as a green prompt when the field validates
                    //"alertTextOk": "* 验证OK",
                    "alertText": "* 此验证不可用"
                    // "alertTextLoad": "* 正在验证，请稍等。"
                },
                //实盘
                "ajax_check_buy_price": {
                    "url": ajaxurl + "ajax.php?m=check_buy_price&jsoncallback=?",
                    "alertText": "* 此价格不可用"
                    //"alertTextLoad": "* 正在验证，请稍等。"
                },
                "ajax_check_buy_volume": {
                    "url": ajaxurl + "ajax.php?m=check_buy_volume&jsoncallback=?",
                    "alertText": "* 此量不可用"
                    //"alertTextLoad": "* 正在验证，请稍等。"
                },
                "ajax_check_sell_price": {
                    "url": ajaxurl + "ajax.php?m=check_sell_price&jsoncallback=?",
                    "alertText": "* 此价格不可用"
                    //"alertTextLoad": "* 正在验证，请稍等。"
                },
                "ajax_check_sell_volume": {
                    "url": ajaxurl + "ajax.php?m=check_sell_volume&jsoncallback=?",
                    "alertText": "* 此量不可用"
                    //"alertTextLoad": "* 正在验证，请稍等。"
                },
                //st
                "ajax_st_check_buy_price": {
                    "url": ajaxurl + "ajax.php?m=st_check_buy_price&jsoncallback=?",
                    "alertText": "* 此价格不可用"
                    //"alertTextLoad": "* 正在验证，请稍等。"
                },
                "ajax_st_check_buy_volume": {
                    "url": ajaxurl + "ajax.php?m=st_check_buy_volume&jsoncallback=?",
                    "alertText": "* 此量不可用"
                    //"alertTextLoad": "* 正在验证，请稍等。"
                },
                "ajax_st_check_sell_price": {
                    "url": ajaxurl + "ajax.php?m=st_check_sell_price&jsoncallback=?",
                    "alertText": "* 此价格不可用"
                    //"alertTextLoad": "* 正在验证，请稍等。"
                },
                "ajax_st_check_sell_volume": {
                    "url": ajaxurl + "ajax.php?m=st_check_sell_volume&jsoncallback=?",
                    "alertText": "* 此量不可用"
                    //"alertTextLoad": "* 正在验证，请稍等。"
                },
                "ajax_check_deposit_amount": {
                    "url": ajaxurl + "ajax.php?m=check_deposit_amount&jsoncallback=?",
                    // you may want to pass extra data on the ajax call
                    //"extraData": "name=eric",
                    // if you provide an "alertTextOk", it will show as a green prompt when the field validates
                    //"alertTextOk": "* OK",
                    "alertText": "* 此量不可用"
                    //"alertTextLoad": "* 正在验证，请稍等。"
                },
                "ajax_check_deposit_amount_tpay": {
                    "url": ajaxurl + "ajax.php?m=check_deposit_amount_tpay&jsoncallback=?",
                    // you may want to pass extra data on the ajax call
                    //"extraData": "name=eric",
                    // if you provide an "alertTextOk", it will show as a green prompt when the field validates
                    //"alertTextOk": "* OK",
                    "alertText": "* 此量不可用"
                    //"alertTextLoad": "* 正在验证，请稍等。"
                },

                "ajax_check_cny_withdraw_amount": {
                    "url": ajaxurl + "ajax.php?m=check_cny_withdraw_amount&jsoncallback=?",
                    // you may want to pass extra data on the ajax call
                    //"extraData": "name=eric",
                    // if you provide an "alertTextOk", it will show as a green prompt when the field validates
                    //"alertTextOk": "* OK",
                    "alertText": "* 此量不可用"
                    //"alertTextLoad": "* 正在验证，请稍等。"
                },
                "ajax_check_btc_withdraw_amount": {
                    "url": ajaxurl + "ajax.php?m=check_btc_withdraw_amount&jsoncallback=?",
                    // you may want to pass extra data on the ajax call
                    "extraData": "name=eric",
                    // if you provide an "alertTextOk", it will show as a green prompt when the field validates
                    //"alertTextOk": "* OK",
                    "alertText": "* 此量不可用"
                    //"alertTextLoad": "* 正在验证，请稍等。"
                },
                "ajaxNameCall": {
                    // remote json service location
                    "url": "ajaxValidateFieldName",
                    // error
                    "alertText": "* 此名称已被其他人使用"
                    // if you provide an "alertTextOk", it will show as a green prompt when the field validates
                    //"alertTextOk": "* 此名称可以使用",
                    // speaks by itself
                    //"alertTextLoad": "* 正在确认名称是否有其他人使用，请稍等。"
                },
                "ajaxTitleCheckCall": {
                    // remote json service location
                    "url": "/admin_seo/ajaxTitleCheckCall",
                    // error
                    "alertText": "* 此标题已经存在"
                    // speaks by itself
                    //"alertTextLoad": "* 正在确认标题是否存在，请稍等。"
                },
                "validate2fields": {
                    "alertText": "* 请输入 HELLO"
                },
                //tls warning:homegrown not fielded 
                "dateFormat": {
                    "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(?:(?:0?[1-9]|1[0-2])(\/|-)(?:0?[1-9]|1\d|2[0-8]))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(0?2(\/|-)29)(\/|-)(?:(?:0[48]00|[13579][26]00|[2468][048]00)|(?:\d\d)?(?:0[48]|[2468][048]|[13579][26]))$/,
                    "alertText": "* 无效的日期格式"
                },
                //tls warning:homegrown not fielded 
                "dateTimeFormat": {
                    "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1}$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^((1[012]|0?[1-9]){1}\/(0?[1-9]|[12][0-9]|3[01]){1}\/\d{2,4}\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1})$/,
                    "alertText": "* 无效的日期或时间格式",
                    "alertText2": "可接受的格式： ",
                    "alertText3": "mm/dd/yyyy hh:mm:ss AM|PM 或 ",
                    "alertText4": "yyyy-mm-dd hh:mm:ss AM|PM"
                }
            };

        }
    };
    $.validationEngineLanguage.newLang();
})(jQuery);

//火币网密码规则校验
function huobi_pwd(field, rules, i, options) {
    var value = field.val();
    var illegalRegEx = new RegExp(options.allrules.illegal.regex);
    var allNumberRegEx = new RegExp(options.allrules.allNumber.regex);
    var allLetterRegEx = new RegExp(options.allrules.allLetter.regex);
    var allCharacterRegEx = new RegExp(options.allrules.allCharacter.regex);
    var allSameRegEx = new RegExp(options.allrules.allSame.regex);

    if (illegalRegEx.test(value)) {
        return options.allrules.illegal.alertText;
    } else if (allNumberRegEx.test(value)) {
        return options.allrules.allNumber.alertText;
    } else if (allLetterRegEx.test(value)) {
        return options.allrules.allLetter.alertText;
    } else if (allCharacterRegEx.test(value)) {
        return options.allrules.allCharacter.alertText;
    } else if (allSameRegEx.test(value)) {
        return options.allrules.allSame.alertText;
    }

}
/**
 * jQuery EnPlaceholder plug
 * EnPlaceholder是一个跨浏览器实现placeholder效果的jQuery插件
 * version 1.0
 * by Frans.Lee <dmon@foxmail.com>  http://www.ifrans.cn
 */
; (function($) {
    $.fn.extend({
        "placeholder": function(options) {
            options = $.extend({
                placeholderColor: '#ACA899',
                isUseSpan: false,
                //是否使用插入span标签模拟placeholder的方式,默认false,默认使用value模拟
                onInput: true //使用标签模拟(isUseSpan为true)时，是否绑定onInput事件取代focus/blur事件
            },
            options);

            $(this).each(function() {
                var _this = this;

                var supportPlaceholder = 'placeholder' in document.createElement('input');
                if (!supportPlaceholder) {
                    var defaultValue = $(_this).attr('placeholder');
                    var defaultColor = $(_this).css('color');
                    if (options.isUseSpan == false) {
                        $(_this).focus(function() {
                            var pattern = new RegExp("^" + defaultValue + "$|^$");
                            pattern.test($(_this).val()) && $(_this).val('').css('color', defaultColor);
                        }).blur(function() {
                            if ($(_this).val() == defaultValue) {
                                $(_this).css('color', defaultColor);
                            } else if ($(_this).val().length == 0) {
                                $(_this).val(defaultValue).css('color', options.placeholderColor)
                            }
                        }).trigger('blur');
                    } else {
                        var $imitate = $('<span class="wrap-placeholder" style="position:absolute; display:inline-block; overflow:hidden; color:' + options.placeholderColor + '; width:' + $(_this).outerWidth() + 'px; height:' + $(_this).outerHeight() + 'px;">' + defaultValue + '</span>');
                        $imitate.css({
                            'margin-left': $(_this).css('margin-left'),
                            'margin-top': $(_this).css('margin-top'),
                            'font-size': $(_this).css('font-size'),
                            'font-family': $(_this).css('font-family'),
                            'font-weight': $(_this).css('font-weight'),
                            'padding-left': parseInt($(_this).css('padding-left')) + 2 + 'px',
                            'line-height': _this.nodeName.toLowerCase() == 'textarea' ? $(_this).css('line-weight') : $(_this).outerHeight() + 'px',
                            'padding-top': _this.nodeName.toLowerCase() == 'textarea' ? parseInt($(_this).css('padding-top')) + 2 : 0
                        });
                        $(_this).before($imitate.click(function() {
                            $(_this).trigger('focus');
                        }));

                        $(_this).val().length != 0 && $imitate.hide();

                        if (options.onInput) {
                            //绑定oninput/onpropertychange事件
                            var inputChangeEvent = typeof(_this.oninput) == 'object' ? 'input': 'propertychange';
                            $(_this).bind(inputChangeEvent,
                            function() {
                                $imitate[0].style.display = $(_this).val().length != 0 ? 'none': 'inline-block';
                            });
                        } else {
                            $(_this).focus(function() {
                                $imitate.hide();
                            }).blur(function() { / ^$ / .test($(_this).val()) && $imitate.show();
                            });
                        }
                    }
                }
            });
            return this;
        }
    });
})(jQuery);

$(document).ready(function() {
    //新版交易中心 买入、卖出比特币 tab标签切换
    $('.trade-center-form-wrapper .trade-center-form-hd span').click(function() {
        $(this).siblings().removeClass('active');
        $('.' + $(this).addClass('active').attr('data-target')).show().siblings().hide();
        if ($(this).attr('id') == 'tab_buy') {
            $('.loan_cny_tips').show();
            $('.loan_btc_tips').hide();
        } else {
            $('.loan_cny_tips').hide();
            $('.loan_btc_tips').show();
        }
    });
    //根据URL链接切换买入、卖出标签
    var hash = window.location.hash;
    if (hash) {
        if (hash == '#buy') {
            $('#tab_buy').siblings().removeClass('active');
            $('.' + $('#tab_buy').addClass('active').attr('data-target')).show().siblings().hide();
            $('.loan_cny_tips').show();
            $('.loan_btc_tips').hide();
        }
        if (hash == '#sell') {
            $('#tab_sell').siblings().removeClass('active');
            $('.' + $('#tab_sell').addClass('active').attr('data-target')).show().siblings().hide();
            $('.loan_cny_tips').hide();
            $('.loan_btc_tips').show();
        }
    }

    $('.level-one-title').click(function() {
        var $levelTwo = $(this).next('ul');
        //如果有二级菜单
        if ($levelTwo.length > 0) {
            $('.level-two').not($levelTwo).hide();
            $levelTwo.toggle();
        }
    });
    //激活顶部导航栏选中状态
    huobi.activeTopNav();
    //激活左侧边栏选中状态
    huobi.activeLeftNav();
    //修补首页登录placeholder
    huobi.attach('.index-login-form input', $.fn.placeholder, {
        isUseSpan: true
    });
    //修补底部固定行情placeholder
    huobi.attach('.hangqing-fixed .trade-form input', $.fn.placeholder, {
        isUseSpan: true
    });
    //启动轮播图
    huobi.attach('.carousel', $.fn.carousel, {
        interval: 8000
    });
    //初始化提示
    huobi.attach('.show_tooltip', $.fn.tooltip);
    //初始化日期选择器
    huobi.attach('.data-picker', $.fn.datepicker, {
        autoSize: true,
        showMonthAfterYear: true,
        dateFormat: 'yy-mm-dd',
        //日期格式，自己设置
        currentText: ' ',
        monthNames: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
        dayNamesShort: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
        dayNamesMin: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]
    });
    //初始化日期选择器（附带时间）
    $('.datatime-picker').datetimepicker();
    //借贷中心  表格折叠行
    $('.collapse_table .repament_detail').click(function() {
        var id = $(this).attr('data-target');
        $('#' + id).toggleClass('hidden').siblings('.tr_in').addClass('hidden');
    });
});
var huobi = {
    //激活顶部导航栏选中状态
    activeTopNav: function() {
        var pathname = window.location.pathname;
        var search = request('a');
        if (search != '') {
            var href = pathname + "?a=" + search;
        } else {
            var href = pathname;
        }
        switch (href) {
        case '/trade/index.php':
        case '/trade/':
        case '/trade/?a=delegation':
        case '/trade/?a=query':
        case '/trade/?a=history':
        case '/trade/?a=depth':
        case '/trade/index.php?a=delegation':
        case '/trade/index.php?a=query':
        case '/trade/index.php?a=history':
        case '/trade/index.php?a=depth':
            //激活顶部导航  交易中心 （新版）
            $(".nav-bar a[href='/trade/index.php']").addClass('current');
            //展开侧边栏  交易中心（新版）
            $(".left-nav-bar .nav-trade-center").next('ul').show();
            break;
        case '/deposit/?a=cny_deposit':
        case '/withdraw/?a=cny_withdraw':
        case '/deposit/?a=btc_deposit':
        case '/withdraw/?a=btc_withdraw':
        case '/deposit/index.php?a=cny_deposit':
        case '/withdraw/index.php?a=cny_withdraw':
        case '/deposit/index.php?a=btc_deposit':
        case '/withdraw/index.php?a=btc_withdraw':
        case '/finance/index.php?a=channels':
        case '/finance/index.php':
            //激活顶部导航  财务中心 （新版）
            $(".nav-bar a[href='/finance/index.php']").addClass('current');
            //展开侧边栏  财务中心（新版）
            $(".left-nav-bar .nav-finance-center").next('ul').show();
            break;
        case '/loan/?a=loan':
        case '/loan/index.php?a=loan':
            //激活顶部导航  借贷中心 （新版）
            $(".nav-bar a[href='/loan/index.php?a=loan']").addClass('current');
            //展开侧边栏  借贷中心（新版）
            $(".left-nav-bar .nav-loan-center").next('ul').show();
            break;
        case '/account/account.php?a=security_center':
        case '/account/account.php?a=bind_phone':
        case '/account/account.php?a=change_trade_passwd':
        case '/account/account.php?a=fund_security':
        case '/account/account.php?a=twofactor':
            //激活顶部导航  安全中心 （新版）
            $(".nav-bar a[href='/account/account.php?a=security_center']").addClass('current');
            //展开侧边栏  安全中心（新版）
            $(".left-nav-bar .nav-safe-center").next('ul').show();
            break;
        case '/account/account.php':
        case '/account/account.php?a=change_passwd':
        case '/account/account.php?a=score':
        case '/account/account.php?a=customer':
        case '/account/account.php?a=invitation':
            //激活顶部导航  用户中心 （新版）
            $(".nav-bar a[href='/account/account.php']").addClass('current');
            //展开侧边栏  用户中心（新版）
            $(".left-nav-bar .nav-user-center").next('ul').show();
            break;
        case '/help/index.php':
            //激活顶部导航  帮助中心 （新版）
            $(".nav-bar a[href='/help/index.php']").addClass('current');
            break;
        default:
            //默认激活顶部导航  首页 （新版）
            $(".nav-bar a[href='/']").addClass('current');
            break;
        }
    },

    activeLeftNav: function() {
        var pathname = window.location.pathname;
        var search = request('a');
        if (search != '') {
            var href = pathname + "?a=" + search;
        } else {
            var href = pathname;
        }
        $(".level-two a[href='" + href + "']").parent('li').addClass('current').prev().find('a').css({
            'border-bottom': 'none'
        });
    },
    //设为首页
    setHome: function(obj, vrl) {
        try {
            obj.style.behavior = 'url(#default#homepage)';
            obj.setHomePage(vrl);
        } catch(e) {
            if (window.netscape) {
                try {
                    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                } catch(e) {
                    show_alert("抱歉！您的浏览器不支持直接设为首页。请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为“true”，点击“加入收藏”后忽略安全提示，即可设置成功。");
                }
                var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                prefs.setCharPref('browser.startup.homepage', vrl);
            } else {
                show_alert('抱歉，您的浏览器不支持自动设置首页, 请使用浏览器菜单手动设置!');
            }
        }
    },
    //加入收藏
    addFavorite: function(sURL, sTitle) {
        sURL = encodeURI(sURL);
        try {
            window.external.addFavorite(sURL, sTitle);
        } catch(e) {
            try {
                window.sidebar.addPanel(sTitle, sURL, "");
            } catch(e) {
                show_alert("加入收藏失败，请使用Ctrl+D进行添加,或手动在浏览器里进行设置.");
            }
        }
    },
    /* 大于昨日收盘价，标红；小于昨日收盘价，标绿；等于，不变色。
   * @param  id   dom元素ID; 例如： '#t_p_new'
   * @param  price  待比较价格
   * @param  lastPrice  待比较价格
   */
    addPriceColor: function(id, price, lastPrice) {
        if (price > lastPrice) {
            $(id).removeClass('tx-green').addClass('tx-red');
        } else if (price < lastPrice) {
            $(id).removeClass('tx-red').addClass('tx-green');
        }
    },
    //给元素绑定处理函数
    //绑定前会检查元素是否存在
    attach: function(selector, func, args) {
        var $that = $(selector);
        if ($that.length !== 0) {
            func.call($that, args);
        }
    }
};
var onlineService = {
    positionQQ: function() {
        if ($('.online-service').length > 0) {
            var offset = $('.online-service').offset();
            var $panel = $('.online-service-inner');
            if (!$panel.hasClass('hidden')) {
                $panel.css({
                    'top': offset.top - 160,
                    'left': offset.left - 8
                })
            }
        }
    },
    //显示客服QQ并定位
    showQQ: function() {
        var $panel = $('.online-service-inner');
        if ($panel.hasClass('hidden')) {
            $panel.removeClass('hidden');
        } else {
            $panel.addClass('hidden');
        }
    }
};
huobi.onlineService = onlineService;
function request(paras) {
    var url = location.href;
    var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
    var paraObj = {};
    for (i = 0; j = paraString[i]; i++) {
        paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
    }
    var returnValue = paraObj[paras.toLowerCase()];
    if (typeof(returnValue) == "undefined") {
        return "";
    } else {
        return returnValue;
    }
}
//from public.js
var maindomain;
if (window.location.protocol === 'https:') {
    maindomain = 'www';
} else {
    maindomain = 'dev.demo';
}
if (window.location.href.indexOf("www.huobi.com") > -1) {
    ajax_baseurl_crossdomain = "https://www.huobi.com/";
} else {
    ajax_baseurl_crossdomain = "http://dev.demo.huobi.com/";
}

//var ajax_baseurl_crossdomain = window.location.protocol + '//' + maindomain + '.huobi.com/';
//首页价格区块
title = document.title;

function servicepriceblock() {
    var requesturl = ajax_baseurl_crossdomain + "market/huobi.php?a=detail&jsoncallback=?";
    $.getJSON(requesturl,
    function(data) {
        var dataObj = data; //转换为json对象
        var lastPrice = dataObj.p_last; //昨日收盘价
        //设置标题显示最新报价
        var pathname = window.location.pathname;
        var search = window.location.search;
        var href = pathname + search;
        switch (href) {
        case '/':
        case '/trade/':
        case '/trade/index.php':
        case '/trade/index.php?a=buy':
        case '/trade/index.php?a=sell':
            var _title = '￥' + dataObj.p_new + '-' + title;
            document.title = _title;
            break;
        }

        $('.hq_t_p_new').html('￥' + dataObj.p_new);
        huobi.addPriceColor('.hq_t_p_new', dataObj.p_new, lastPrice);
        $('.hq_t_p_open').html('￥' + dataObj.p_open);
        $('.hq_t_p_last').html('￥' + dataObj.p_last);
        $('.hq_t_level').html(dataObj.level);
        //涨幅
        $('.hq_t_amp').html(dataObj.amp + '%');
        $('.hq_t_amount').html('฿' + dataObj.amount);
        $('.hq_t_p_high').html('￥' + dataObj.p_high);
        huobi.addPriceColor('.hq_t_p_high', dataObj.p_high, lastPrice);
        $('.hq_t_p_low').html('￥' + dataObj.p_low);
        huobi.addPriceColor('.hq_t_p_low', dataObj.p_low, lastPrice);
        if (dataObj.sells) {
            //最佳买价
            if (dataObj.sells[0] != undefined) {
                if (dataObj.sells[0]['price']) {
                    $('#zuijiamaijia').html(dataObj.sells[0]['price']);
                }
            }
            //卖十
            for (sell in dataObj.sells) {
                $('#t_sell_' + sell + '_p').html('￥' + dataObj.sells[sell]['price']);
                $('#t_sell_' + sell + '_m').html('฿' + dataObj.sells[sell]['amount']);
                huobi.addPriceColor('#t_sell_' + sell + '_p', dataObj.sells[sell]['price'], lastPrice);
            }
            $('.hq_sell_1').html('￥' + dataObj.sells[0]['price']);
        }
        if (dataObj.buys) {
            //最佳卖价
            if (dataObj.buys[0] != undefined) {
                if (dataObj.buys[0]['price']) {
                    $('#zuijiamaijia_o').html(dataObj.buys[0]['price']);
                }
            }
            //买十
            for (buy in dataObj.buys) {
                $('#t_buy_' + buy + '_p').html('￥' + dataObj.buys[buy]['price']);
                $('#t_buy_' + buy + '_m').html('฿' + dataObj.buys[buy]['amount']);
                huobi.addPriceColor('#t_buy_' + buy + '_p', dataObj.buys[buy]['price'], lastPrice);
            }
            $('.hq_buy_1').html('￥' + dataObj.buys[0]['price']);
        }
        //trades
        if (dataObj.trades) {
            var tbody = '';
            for (tradeindex in dataObj.trades) {
                if (dataObj.p_new > dataObj.p_open) {
                    var css = 'normal_red';
                } else {
                    var css = 'normal_gre';
                }
                tbody += '<tr><td>' + dataObj.trades[tradeindex]['time'] + '</td><td class="' + css + '">' + dataObj.trades[tradeindex]['price'] + '</td><td>' + dataObj.trades[tradeindex]['amount'] + '</td><td>' + dataObj.trades[tradeindex]['type'] + '</td></tr>';
            }
            $('#t_trades').html(tbody);
        }

        // 买卖五
        if (dataObj.top_sell && dataObj.top_buy) {
            var Obj_Sell = dataObj.top_sell;
            var Obj_Buy = dataObj.top_buy;
            var html = '';
            if (Obj_Sell[0] != undefined) {
                $('#zuijiamaijia').html(BtcRound(Obj_Sell[0]['price'], 3));
            }
            for (var i = 0; i < 5; i++) {
                css = Obj_Sell[i]["level"] == 1 ? 'text-error': 'text-success';
                if (i == 0) css += ' border_bottom_red';
                var _tmp_html = '';
                _tmp_html += "<tr class='" + css + "' style=\"cursor: pointer;\" onclick='change_buy_form(this)'>";
                _tmp_html += "<td>卖(" + (i - 0 + 1) + ")</td>";
                _tmp_html += "<td>￥<span class='_sub_price'>" + Obj_Sell[i]['price'] + "</span></td>";
                _tmp_html += "<td><span>" + Obj_Sell[i]['amount'] + "</span></td>";
                _tmp_html += "<td><span class='_sub_amount'>" + Obj_Sell[i]['accu'] + "</span></td>";
                _tmp_html += "</tr>";
                html = _tmp_html + html;
            }
            if (Obj_Buy[0] != undefined) {
                $('#zuijiamaijia_o').html(BtcRound(Obj_Buy[0]['price'], 3));
            }
            for (var i = 0; i < 5; i++) {
                if (i == 5) break;
                css = Obj_Buy[i]["level"] == 1 ? 'text-error': 'text-success';
                html += "<tr class='" + css + "' style=\"cursor: pointer;\" onclick='change_sell_form(this)'>";
                html += "<td>买(" + (i - 0 + 1) + ")</td>";
                html += "<td>￥<span class='_sub_price'>" + Obj_Buy[i]['price'] + "</span></td>";
                html += "<td><span>" + Obj_Buy[i]['amount'] + "</span></td>";
                html += "<td><span class='_sub_amount'>" + Obj_Buy[i]['accu'] + "</span></td>";
                html += "</tr>";
            }
            $('.trade_market_depth').html(html);
        }
    });
}

//记录用户的资产情况变量
user_available_cny = 0;
user_available_btc = 0;
//更新可卖出量及当前余额
function btc_trade_amount_balance() {
    $.getJSON('/account/ajax.php?m=my_trade_info',
    function(data) {
        var dataObj = data; //转换为json对象
        //alert(dataObj.extra['order_price']);
        if (dataObj.code) {
            return;
        }
        //账户资金为0时，提示充值
        if (dataObj.extra != undefined) {
            if (dataObj.extra.balance['total'] === "0.00") {
                $('#alert_no_money').show();
            }
            $('#kemaichuliang_o').html(dataObj.extra.sell['amount']);
            $('#max_volume').html(dataObj.extra.sell['amount']);
            $('#dangqianyue_o').html(dataObj.extra.sell['available_btc']);
            //buy
            $('#kemairuliang_o').html(dataObj.extra.buy['amount']);
            $('#kemairuliang').html(dataObj.extra.buy['amount']);
            $('#dangqianyue').html(dataObj.extra.buy['available_cny']);
            //balance
            if (dataObj.extra.balance && dataObj.extra != undefined) {
                if (dataObj.extra.balance['total'] != undefined) {
                    if (dataObj.extra.balance['total'] !== '0.00') {
                        $('.user_total').html('<b>' + dataObj.extra.balance['total'] + '</b>');
                    } else {
                        $('.user_total').html(dataObj.extra.balance['total']);
                    }
                }
                if (dataObj.extra.balance['net_asset'] != undefined) {
                    if (dataObj.extra.balance['net_asset'] !== '0.00') {
                        $('.user_net_asset').html('<b>' + dataObj.extra.balance['net_asset'] + '</b>');
                    } else {
                        $('.user_net_asset').html(dataObj.extra.balance['net_asset']);
                    }
                }
                if (dataObj.extra.balance['available_cny_display'] != undefined) {
                    if (dataObj.extra.balance['available_cny_display'] !== '0.00') {
                        user_available_cny = dataObj.extra.balance['available_cny_display'];
                        $('.user_available_cny').html('<b>' + dataObj.extra.balance['available_cny_display'] + '</b>');
                    } else {
                        $('.user_available_cny').html(dataObj.extra.balance['available_cny_display']);
                    }
                }
                if (dataObj.extra.balance['available_btc_display'] != undefined) {
                    if (dataObj.extra.balance['available_btc_display'] !== '0.0000') {
                        user_available_btc = dataObj.extra.balance['available_btc_display'];
                        $('.user_available_btc').html('<b>' + dataObj.extra.balance['available_btc_display'] + '</b>');
                    } else {
                        $('.user_available_btc').html(dataObj.extra.balance['available_btc_display']);
                    }
                }
                if (dataObj.extra.balance['frozen_cny_display'] != undefined) {
                    if (dataObj.extra.balance['frozen_cny_display'] !== '0.00') {
                        $('.user_frozen_cny').html('<b>' + dataObj.extra.balance['frozen_cny_display'] + '</b>');
                    } else {
                        $('.user_frozen_cny').html(dataObj.extra.balance['frozen_cny_display']);
                    }
                }
                if (dataObj.extra.balance['frozen_btc_display'] != undefined) {
                    if (dataObj.extra.balance['frozen_btc_display'] !== '0.0000') {
                        $('.user_frozen_btc').html('<b>' + dataObj.extra.balance['frozen_btc_display'] + '</b>');
                    } else {
                        $('.user_frozen_btc').html(dataObj.extra.balance['frozen_btc_display']);
                    }
                }
                if (dataObj.extra.balance['loan_cny_display'] != undefined) {
                    if (dataObj.extra.balance['loan_cny_display'] !== '0.00') {
                        $('.user_loan_cny').html('<b>' + dataObj.extra.balance['loan_cny_display'] + '</b>');
                    } else {
                        $('.user_loan_cny').html(dataObj.extra.balance['loan_cny_display']);
                    }
                }
                if (dataObj.extra.balance['loan_btc_display'] != undefined) {
                    if (dataObj.extra.balance['loan_btc_display'] !== '0.0000') {
                        $('.user_loan_btc').html('<b>' + dataObj.extra.balance['loan_btc_display'] + '</b>');
                    } else {
                        $('.user_loan_btc').html(dataObj.extra.balance['loan_btc_display']);
                    }
                }
            }
        }
    });
}

function change_buy_form(e) {
    var price = $(e).find('._sub_price').html();
    var amount = $(e).find('._sub_amount').html();
    //根据当前可用人民币，计算最大可买入量
    user_available_cny = parseFloat(user_available_cny);
    if (user_available_cny) {
        var amount_tmp = user_available_cny / price;
        amount_tmp = parseInt(amount_tmp * 10000);
        amount_tmp = amount_tmp / 10000;
        if (amount_tmp <= amount) {
            amount = amount_tmp;
        }
    }
    $('#form_add_buy_btc #mairujia').val(price);
    $('#form_add_buy_btc #mairuliang').val(amount);
    $('#form_add_buy_btc #mairujia').trigger('change');
    $('#tab_buy').siblings().removeClass('active');
    $('.' + $('#tab_buy').addClass('active').attr('data-target')).show().siblings().hide();
    //底部浮动框
    $('#form_add_buy_btc2 #mairujia2').val(price);
    $('#form_add_buy_btc2 #mairuliang2').val(amount);
    $('#form_add_buy_btc2 #mairujia2').trigger('change');
}
function change_sell_form(e) {
    var price = $(e).find('._sub_price').html();
    var amount = $(e).find('._sub_amount').html();
    //根据当前用户可用比特币，填入相应数量
    user_available_btc = parseFloat(user_available_btc);
    if (user_available_btc) {
        var amount_tmp = user_available_btc;
        if (amount_tmp <= amount) {
            amount = amount_tmp;
        }
    }
    $('#form_add_sell_btc #price').val(price);
    $('#form_add_sell_btc #volume').val(amount);
    $('#form_add_sell_btc #price').trigger('change');
    $('#tab_sell').siblings().removeClass('active');
    $('.' + $('#tab_sell').addClass('active').attr('data-target')).show().siblings().hide();
    //底部浮动框
    $('#form_add_sell_btc2 #price2').val(price);
    $('#form_add_sell_btc2 #volume2').val(amount);
    $('#form_add_sell_btc2 #price2').trigger('change');
}

//验证码
function reload_captcha() {
    $("#captcha_img").attr('src', '/captcha/index.php?' + Math.random());
}

//两个验证码时
function getsms_2(phoneId, spanId, smsId) {
    var phone = $('#' + phoneId).val();
    if (phone == '') {
        show_alert("手机号码不能为空");
        return;
    }
    reg = /[0-9]+/;
    if (reg.test($('#' + spanId).html())) {
        return false;
    }
    $.get('/account/ajax.php?m=send_sms&id=' + smsId + '&phone=' + phone,
    function(data) {
        if (data.code == 99) {
            show_alert('您一个小时内，已连续发送12次手机验证码，请1小时后再试……');
            return false;
        }
        if (data.code != 0) {
            show_alert('短信发送失败，请稍候重试!');
        }
    });
    sendMessage(spanId);
    $('#' + phoneId).attr("readonly", "readonly");
}

//无需页面显示手机号码
function getsmsv2(spanId, smsId) {
    reg = /[0-9]+/;
    if (reg.test($('#' + spanId).html())) {
        return false;
    }
    $.get('/account/ajax.php?m=send_sms_v2&id=' + smsId,
    function(data) {
        if (data.code == 99) {
            show_alert('您一个小时内，已连续发送12次手机验证码，请1小时后再试……');
            return false;
        }
        if (data.code != 0) {
            show_alert('短信发送失败，请稍候重试!');
        }
    });
    sendMessage2(spanId);
}
/*-------------------------------------------*/
var InterValObj;
//timer变量，控制时间
var count = 60;
//间隔函数，1秒执行
var curCount;
//当前剩余秒数
function sendMessage(btnid) {
    curCount = count;
    //设置button效果，开始计时
    $("#" + btnid).attr("disabled", "true");
    $("#" + btnid).html("" + curCount + "秒后重新获取验证码");

    InterValObj = window.setInterval(function() {
        setRemainTime(btnid);
    },
    1000);
    //启动计时器，1秒执行一次
}
//timer处理函数
function setRemainTime(btnid) {
    if (curCount == 0) {
        window.clearInterval(InterValObj);
        //停止计时器
        $("#" + btnid).removeAttr("disabled");
        //启用按钮
        $("#" + btnid).html("重新发送验证码");
    } else {
        curCount--;
        $("#" + btnid).html("" + curCount + "秒后重新获取验证码");
    }
}
/*-------------------------------------------*/
var InterValObj2;
//timer变量，控制时间
var count2 = 60;
//间隔函数，1秒执行
var curCount2;
//当前剩余秒数
function sendMessage2(btnid2) {
    curCount2 = count2;
    //设置button效果，开始计时
    $("#" + btnid2).attr("disabled", "true");
    $("#" + btnid2).html("" + curCount2 + "秒后重新获取验证码");
    InterValObj2 = window.setInterval(function() {
        setRemainTime2(btnid2);
    },
    1000);
    //启动计时器，1秒执行一次
}
//timer处理函数
function setRemainTime2(btnid) {
    if (curCount2 == 0) {
        window.clearInterval(InterValObj2);
        //停止计时器
        $("#" + btnid).removeAttr("disabled");
        //启用按钮
        $("#" + btnid).html("重新发送验证码");
    } else {
        curCount2--;
        $("#" + btnid).html("" + curCount2 + "秒后重新获取验证码");
    }
}
// /sell
function BtcRound(num, n) {
    var dd = 1;
    var tempnum;
    for (i = 0; i < n; i++) {
        dd *= 10;
    }
    tempnum = num * dd;
    tempnum = Math.round(tempnum);
    return (tempnum / dd);
}
//general form
//表单验证
jQuery(document).ready(function() {
    jQuery("#form1").validationEngine({
        validationEventTriggers: "blur",
        success: false,
        promptPosition: "bottomRight"
    });
    $('#amt').blur(function() {
        calTixianCny();
    });
    $('#bank').change(function() {
        calTixianCny();
    });

    jQuery("#change_google_code").validationEngine({
        promptPosition: 'topRight'
    });

});
//计算提现手续费
function calTixianCny() {
    var my_channel_id = $('#bank').val();
    var amount = $('#amt').val();
    $.getJSON(ajax_baseurl_crossdomain + 'account/ajax.php?m=get_tixian_fee&jsoncallback=?&amt=' + amount + '&my_channel_id=' + my_channel_id,
    function(data) {
        var dataObj = data; //转换为json对象
        if (dataObj.code) {
            show_alert(dataObj.msg);
            return;
        }
        $('#amt_fee').val(dataObj.extra);
    });
}

is_trade_ajax = false;

// 卖出
jQuery(document).ready(function() {
    jQuery("#form_add_sell_btc").validationEngine({
        promptPosition: 'topRight',
        oneSubmitNum: false
    });
    //离开兑换额的时候计算
    $("#form_add_sell_btc #duihuane_o").focus(function() {
        calSellDuihuane();
    });
    $("#form_add_sell_btc #volume").change(function() {
        calSellDuihuane();
    });
    $("#form_add_sell_btc #price").change(function() {
        calSellDuihuane();
    });
    //卖出兑换额
    function calSellDuihuane() {
        $("#form_add_sell_btc #duihuane_o").val(BtcRound($("#form_add_sell_btc #price").val() * $("#form_add_sell_btc #volume").val(), 4));
    }

    //卖出AJAX表单提交
    jQuery('#form_add_sell_btc').submit(function() {
        if ($('#form_add_sell_btc').validationEngine('validate') == false) {
            return false;
        }
        if (is_trade_ajax) return false;
        var sell_price = $('#price').val();
        var sell_amount = $('#volume').val();
        var sell_password = $('#zhifumima_o').val();
        if (sell_price == '' || sell_amount == '' || sell_password == '') {
            return false;
        }
        is_trade_ajax = true;
        $.ajax({
            cache: false,
            url: '/trade/index.php',
            type: 'post',
            data: {
                a: 'do_sell',
                price: sell_price,
                amount: sell_amount,
                password: sell_password
            },
            dataType: 'json',
            beforeSend: function() {
                $(this).find('.sell-btn').html('正在处理,请稍候...');
            },
            success: function(data) {
                if (data.code == 0) {
                    show_trade_alert(data.msg);
                    $('#volume').val('');
                    $('#price').val('');
                    $('#duihuane_o').val('');
                    $('#zhifumima_o').val('');
                } else {
                    show_alert(data.msg);
                }
                is_trade_ajax = false;
            },
            complete: function() {
                $(this).find('.sell-btn').html('卖出 （BTC-CNY）');
            }
        });
        return false;
    });
    // 卖出AJAX end

    // 底部浮动框
    jQuery("#form_add_sell_btc2").validationEngine({
        promptPosition: 'topRight',
        oneSubmitNum: false
    });
    $("#form_add_sell_btc2 #volume2").change(function() {
        calSellDuihuane2();
    });
    $("#form_add_sell_btc2 #price2").change(function() {
        calSellDuihuane2();
    });
    $("#form_add_sell_btc2 #duihuane_o2").focus(function() {
        calSellDuihuane2();
    });
    //卖出兑换额
    function calSellDuihuane2() {
        var duihuane = BtcRound($("#form_add_sell_btc2 #price2").val() * $("#form_add_sell_btc2 #volume2").val(), 4);
        $("#form_add_sell_btc2 #duihuane_o2").val(duihuane);
        $("#form_add_sell_btc2 #duihuane_o2").html(duihuane + ' CNY');
    }

    //卖出2AJAX表单提交
    jQuery('#form_add_sell_btc2').submit(function() {
        if ($('#form_add_sell_btc2').validationEngine('validate') == false) {
            return false;
        }
        if (is_trade_ajax) return false;
        var sell_price = $('#price2').val();
        var sell_amount = $('#volume2').val();
        var sell_password = $('#zhifumima_o2').val();
        if (sell_price == '' || sell_amount == '' || sell_password == '') {
            return false;
        }
        is_trade_ajax = true;
        $.ajax({
            cache: false,
            url: '/trade/index.php',
            type: 'post',
            data: {
                a: 'do_sell',
                price: sell_price,
                amount: sell_amount,
                password: sell_password
            },
            dataType: 'json',
            beforeSend: function() {
                $('#form_add_sell_btc2 .sell').html('Load...');
            },
            success: function(data) {
                if (data.code == 0) {
                    show_trade_alert(data.msg);
                    $('#volume2').val('');
                    $('#price2').val('');
                    $('#duihuane_o2').val('');
                    $('#duihuane_o2').html('0 CNY');
                    $('#zhifumima_o2').val('');
                } else {
                    show_alert(data.msg);
                }
                is_trade_ajax = false;
            },
            complete: function() {
                $('#form_add_sell_btc2 .sell').html('卖出');
            }
        });
        return false;
    });
    // 卖出AJAX end
});
//sell end
// 买入
jQuery(document).ready(function() {
    jQuery("#form_add_buy_btc").validationEngine({
        promptPosition: 'topRight',
        oneSubmitNum: false
    });
    //离开兑换额的时候计算
    $("#form_add_buy_btc #duihuane").focus(function() {
        calBuyDuihuane();
    });
    $("#form_add_buy_btc #mairuliang").change(function() {
        calBuyDuihuane();
    });
    $("#form_add_buy_btc #mairujia").change(function() {
        calBuyDuihuane();
        calMaxBuyAmount();
    });
    //卖出兑换额
    function calBuyDuihuane() {
        $("#form_add_buy_btc #duihuane").val(BtcRound($("#form_add_buy_btc #mairujia").val() * $("#form_add_buy_btc #mairuliang").val(), 4));
    }
    //计算最大买入量
    function calMaxBuyAmount() {
        var yue = $('#form_add_buy_btc #dangqianyue').html();
        var price = $('#form_add_buy_btc #mairujia').val();
        $('#form_add_buy_btc #max_kemairuliang').html(BtcRound(yue / price, 4));
    }

    //买入AJAX表单提交
    jQuery('#form_add_buy_btc').submit(function() {
        if ($('#form_add_buy_btc').validationEngine('validate') == false) {
            return false;
        }
        if (is_trade_ajax) return false;
        var buy_price = $('#mairujia').val();
        var buy_amount = $('#mairuliang').val();
        var buy_password = $('#zhifumima').val();
        if (buy_price == '' || buy_amount == '' || buy_password == '') {
            return false;
        }
        is_trade_ajax = true;
        $.ajax({
            cache: false,
            url: '/trade/index.php',
            type: 'post',
            data: {
                a: 'do_buy',
                price: buy_price,
                amount: buy_amount,
                password: buy_password
            },
            dataType: 'json',
            beforeSend: function() {
                $('#form_add_buy_btc .buy_btn').html('正在处理,请稍候...');
            },
            success: function(data) {
                if (data.code == 0) {
                    show_trade_alert(data.msg);
                    $('#mairujia').val('');
                    $('#mairuliang').val('');
                    $('#duihuane').val('');
                    $('#zhifumima').val('');
                } else {
                    show_alert(data.msg);
                }
                is_trade_ajax = false;
            },
            complete: function() {
                $('#form_add_buy_btc .buy_btn').html('买入 （BTC-CNY）');
            }
        });
        return false;
    });
    // 买入AJAX end

    //底部浮动框
    jQuery("#form_add_buy_btc2").validationEngine({
        promptPosition: 'topRight',
        oneSubmitNum: false
    });
    //离开兑换额的时候计算
    $("#form_add_buy_btc2 #duihuane2").focus(function() {
        calBuyDuihuane2();
    });
    $("#form_add_buy_btc2 #mairuliang2").change(function() {
        calBuyDuihuane2();
    });
    $("#form_add_buy_btc2 #mairujia2").change(function() {
        calBuyDuihuane2();
    });
    //卖出兑换额
    function calBuyDuihuane2() {
        var duihuane = BtcRound($("#form_add_buy_btc2 #mairujia2").val() * $("#form_add_buy_btc2 #mairuliang2").val(), 4);
        $("#form_add_buy_btc2 #duihuane2").val(duihuane);
        $("#form_add_buy_btc2 #duihuane2").html(duihuane + ' CNY');
    }

    //买入2AJAX表单提交
    jQuery('#form_add_buy_btc2').submit(function() {
        if ($('#form_add_buy_btc2').validationEngine('validate') == false) {
            return false;
        }
        if (is_trade_ajax) return false;
        var buy_price = $('#mairujia2').val();
        var buy_amount = $('#mairuliang2').val();
        var buy_password = $('#zhifumima2').val();
        if (buy_price == '' || buy_amount == '' || buy_password == '') {
            return false;
        }
        is_trade_ajax = true;
        $.ajax({
            cache: false,
            url: '/trade/index.php',
            type: 'post',
            data: {
                a: 'do_buy',
                price: buy_price,
                amount: buy_amount,
                password: buy_password
            },
            dataType: 'json',
            beforeSend: function() {
                $('#form_add_buy_btc2 .buy').html('Load...');
            },
            success: function(data) {
                if (data.code == 0) {
                    show_trade_alert(data.msg);
                    $('#mairujia2').val('');
                    $('#mairuliang2').val('');
                    $('#duihuane2').val('');
                    $('#duihuane2').html('0 CNY');
                    $('#zhifumima2').val('');
                } else {
                    show_alert(data.msg);
                }
                is_trade_ajax = false;
            },
            complete: function() {
                $('#form_add_buy_btc2 .buy').html('买入');
            }
        });
        return false;
    });
    // 买入2AJAX end
});

//修改买入和卖出时ajax
function buy_btc_edit(id) {
    $.getJSON(ajax_baseurl_crossdomain + 'account/ajax.php?m=get_order&jsoncallback=?&id=' + id,
    function(data) {
        var dataObj = data; //转换为json对象
        if (dataObj.code) {
            show_alert(dataObj.msg);
            return;
        }
        $('.modal #buy_btc_id').val(id);
        $('.modal #mairujia_m').val(dataObj.extra['order_price']);
        $('.modal #mairuliang_m').val(dataObj.extra['order_amount']);
        $(".modal #duihuane_m").val(BtcRound($(".modal #mairujia_m").val() * $(".modal #mairuliang_m").val(), 5));
    });
}
function sell_btc_edit(id) {
    $.getJSON(ajax_baseurl_crossdomain + 'account/ajax.php?m=get_order&jsoncallback=?&id=' + id,
    function(data) {
        var dataObj = data; //转换为json对象
        if (dataObj.code) {
            show_alert(dataObj.msg);
            return;
        }
        $('.modal #sell_btc_id').val(id);
        $('.modal #price_m').val(dataObj.extra['order_price']);
        $('.modal #volume_m').val(dataObj.extra['order_amount']);
        $(".modal #duihuane_o_m").val(BtcRound($(".modal #price_m").val() * $(".modal #volume_m").val(), 5));
    });
}

//修改时ajax验证
jQuery(document).ready(function() {
    jQuery(".modal #form_sell_btc").validationEngine({
        promptPosition: 'topRight'
    });
    //离开兑换额的时候计算
    $(".modal #duihuane_o_m").focus(function() {
        calSellDuihuanem();
    });
    $(".modal #volume_m").change(function() {
        calSellDuihuanem();
    });
    $(".modal #price_m").change(function() {
        calSellDuihuanem();
    });
    //卖出兑换额
    function calSellDuihuanem() {
        $(".modal #duihuane_o_m").val(BtcRound($(".modal #price_m").val() * $(".modal #volume_m").val(), 5));
    }
});
//sell end
jQuery(document).ready(function() {
    jQuery("#form_buy_btc").validationEngine({
        promptPosition: 'topRight'
    });
    //离开兑换额的时候计算
    $(".modal #duihuane_m").focus(function() {
        calBuyDuihuanem();
    });
    $(".modal #mairuliang_m").change(function() {
        calBuyDuihuanem();
    });
    $(".modal #mairujia_m").change(function() {
        calBuyDuihuanem();
    });
    //卖出兑换额
    function calBuyDuihuanem() {
        $(".modal #duihuane_m").val(BtcRound($(".modal #mairujia_m").val() * $(".modal #mairuliang_m").val(), 5));
    }
});

//loan begin
jQuery(document).ready(function() {
    jQuery("#form_add_load_rmb").validationEngine({
        promptPosition: 'topRight'
    });
    $('#form_add_load_rmb #currency_cny').blur(function() {
        var currency = parseFloat($(this).val());
        if (isNaN(currency)) currency = 0;
        var interest_ll = parseFloat($('#form_add_load_rmb #interest_ll_cny').val());
        var interest = BtcRound(currency * interest_ll, 3);
        var curr_count = BtcRound(currency + interest, 3);
        $('#form_add_load_rmb #interest_cny').val(interest);
        $('#form_add_load_rmb #count_cny').val(curr_count);
    });
});
jQuery(document).ready(function() {
    jQuery("#form_add_load_btc").validationEngine({
        promptPosition: 'topRight'
    });
    $('#form_add_load_btc #currency_btc').blur(function() {
        var currency = parseFloat($(this).val());
        if (isNaN(currency)) currency = 0;
        var interest_ll = parseFloat($('#form_add_load_btc #interest_ll_btc').val());
        var interest = BtcRound(currency * interest_ll, 4);
        var curr_count = BtcRound(currency + interest, 4);
        $('#form_add_load_btc #interest_btc').val(interest);
        $('#form_add_load_btc #count_btc').val(curr_count);
    });
});
//弹框提示警告风险
function loan_alert(type) {
    if (!$('#' + type).validationEngine('validate')) {
        return false;
    }
    $('#loan_submit_form_id').html(type);
    $('#show_loan_alert_dialog').trigger('click');
}
//提交借贷表单
function loan_submit() {
    var type = $('#loan_submit_form_id').html();
    if (!$('#' + type).validationEngine('validate')) {
        return false;
    }
    $('#' + type).submit();
}

jQuery(document).ready(function() {
    jQuery("#form_repayment_rmb").validationEngine({
        promptPosition: 'topRight'
    });
});
jQuery(document).ready(function() {
    jQuery("#form_repayment_btc").validationEngine({
        promptPosition: 'topRight'
    });
});

function loan_repayment_cny(id, type) {
    $.getJSON(ajax_baseurl_crossdomain + 'account/ajax.php?m=get_loan&jsoncallback=?&id=' + id,
    function(data) {
        var dataObj = data; //转换为json对象
        if (dataObj.code) {
            show_alert(dataObj.msg);
            return;
        }
        $('.repayment_loan_id').val(id);
        $('#dangqianqiankuan').html(dataObj.extra['cur_total']);
        $('#dangqianqianbi').html(dataObj.extra['cur_total']);
        if (type == 'quankuan') {
            if (dataObj.extra['type'] == 1) {
                $('#currency_mr').val(dataObj.extra['cur_total']);
                $('#currency_mr').attr('readonly', 'readonly');
                $('#_form_repayment_rmb_div').hide();
                var notice_msg = "您确认要还全款吗？<br />确认后将从你的账户里扣除本次借贷本息共计" + dataObj.extra['cur_total'] + "元。";
                $('#_form_repayment_rmb_notice').html(notice_msg);
                $('#_form_repayment_rmb_notice').show();
            } else {
                $('#currency_mt').val(dataObj.extra['cur_total']);
                $('#currency_mt').attr('readonly', 'readonly');
                $('#_form_repayment_btc_div').hide();
                var notice_msg = "您确认要还全款吗？<br />确认后将从你的账户里扣除本次借贷本息共计" + dataObj.extra['cur_total'] + "BTC。";
                $('#_form_repayment_btc_notice').html(notice_msg);
                $('#_form_repayment_btc_notice').show();
            }
        } else {
            if (dataObj.extra['type'] == 1) {
                $('#currency_mr').val('');
                $('#currency_mr').attr('readonly', false);
                $('#_form_repayment_rmb_div').show();
                $('#_form_repayment_rmb_notice').hide();
            } else {
                $('#currency_mt').val('');
                $('#currency_mt').attr('readonly', false);
                $('#_form_repayment_btc_div').show();
                $('#_form_repayment_btc_notice').hide();
            }
        }
        if (dataObj.extra['type'] == 1) {
            $('#currency_mr').attr('class', 'validate[required,custom[loanRmbSp],min[0.001],max[' + dataObj.extra['cur_total'] + ']] text-input');
        } else {
            $('#currency_mt').attr('class', 'validate[required,custom[loanBtcSp],min[0.0001],max[' + dataObj.extra['cur_total'] + ']] text-input');
        }
    });
}
//loan end
// 资产安全表单验证
jQuery(document).ready(function() {
    jQuery("#fund_security").validationEngine({
        promptPosition: 'topRight'
    });
});

//获取中奖用户交易倒计时
jQuery(document).ready(function() {
    $.getJSON(ajax_baseurl_crossdomain + 'account/ajax.php?m=get_user_last_order_time&jsoncallback=?',
    function(data) {
        var dataObj = data; //转换为json对象
        if (dataObj.code != 0) {
            return;
        }
        var order_time = dataObj.time;
        if (order_time <= 0) return;
        var minute = parseInt(order_time / 60);
        var second = order_time % 60;
        var msg = '还有';
        if (minute != 0) {
            msg += '<span class="order_count_minute">' + minute + '</span>分'
        }
        msg += '<span class="order_count_second">' + second + '</span>秒即可进行下单交易'$('.order_count_down').html(msg);
        $('.order_count_down').show();
        timerID = setInterval(function() {
            order_count_down();
        },
        1000);
    });
});

function order_count_down() {
    var minute = $('.order_count_minute').html();
    var second = $('.order_count_second').html();
    minute = parseInt(minute);
    second = parseInt(second);
    if (isNaN(minute)) minute = 0;
    if (isNaN(second)) second = 0;
    second -= 1;
    if (second <= 0) {
        minute -= 1;
        if (minute < 0) {
            second = 0;
        } else {
            second = 60;
        }
    }
    if (minute <= 0 && second <= 0) {
        $('.order_count_down').hide();
        clearInterval(timerID);
        return true;
    }
    var msg = '还有';
    if (minute != 0) {
        msg += '<span class="order_count_minute">' + minute + '</span>分'
    }
    msg += '<span class="order_count_second">' + second + '</span>秒即可进行下单交易'$('.order_count_down').html(msg);
    $('.order_count_down').show();
}

jQuery(document).ready(function() {
    //监听验证码的输入
    $('#vcode').keyup(function() {
        var vcode = $('#vcode').val();
        if (vcode.length == 5) {
            $('#vcode').validationEngine('validate');
        }
    });
});

function show_alert(msg) {
    $('#show_alert_msg').html(msg);
    $('#show_alert_dialog').trigger('click');
}

function show_trade_alert(msg) {
    $('#show_trade_alert_msg').html(msg);
    $('#show_trade_alert_dialog').trigger('click');
}

jQuery(document).ready(function() {
    //顶部导航栏右侧用户信息
    //  $('.user-info-wrapper').hover(function () {
    //    $('.user-info-inner').slideDown();
    //    $('.user-info-outter .arrow').removeClass('arrow-down').addClass('arrow-up');
    //  }, function () {
    //    $('.user-info-inner').stop().slideUp(function(){
    //      $(this).removeAttr('style');
    //    });
    //    $('.user-info-outter .arrow').removeClass('arrow-up').addClass('arrow-down');
    //  });
    $('.user-info-wrapper').click(function() {
        $('.user-info-inner').slideToggle();
        $('.user-info-outter .arrow').toggleClass('arrow-up', 'arrow-down');
    });
    $('.user-info-inner').click(function(event) {
        event.stopPropagation();
    });

    $(window).scroll(function() {
        //视口高度
        var viewportHeight = $(window).height();
        //文档高度
        var documentHeight = $(document).height();
        //滚动高度
        var scorllTop = $(document).scrollTop();

        //如果滚动屏幕到导航条以下，则显示  返回顶部
        /*var $navBar=$('.nav-bar');
    if(scorllTop>$navBar.offset().top+$navBar.height()){
      $('.goto-top').fadeIn();
    }else{
      $('.goto-top').fadeOut();
    }*/

        //如果滚动接近文档底部，则将.hangqing-fixed固定住
        var $hangqing = $('.hangqing-fixed');
        var position = documentHeight - scorllTop - viewportHeight;
        if (position < $('.footer-v2').outerHeight()) {
            $hangqing.css({
                'position': 'relative',
                'margin-top': '30px'
            });
        } else {
            $hangqing.css({
                'position': 'fixed'
            });
        }
        //定位客服QQ
        huobi.onlineService.positionQQ();
    });
    $('.hangqing-outter').click(function() {
        var $mask = $('.hangqing-fixed-mask');
        if (!$mask.hasClass('show')) {
            //判断hangqing-fixed目前的定位是fixed还是relative
            if ($('.hangqing-fixed').css('position') === "relative") {
                //向上滚动窗口，使hangqing-fixed滚动到页面底部
                var distance = $(this).offset().top - $(window).height() + $(this).height();
                $('body').animate({
                    scrollTop: distance
                },
                1000);
            }

            $('.hangqing-inner .market_flash').html('<iframe src="/market/huobi.php?a=market_flash_huobi&version=20130807" height="440px" width="660px" frameborder="0" cellpadding="0" cellspacing="0"></iframe>');
            $mask.addClass('show').animate({
                opacity: 0.6
            });
            $('.hangqing-inner').animate({
                'height': '543px'
            });
        } else {
            hideHangQingInner();
        }
    });
    $('.close-inner').click(function() {
        hideHangQingInner();
    });
    $('.hangqing-fixed-mask').click(function() {
        hideHangQingInner();
    });
    //在线客服
    $('.online-service').click(function() {
        huobi.onlineService.showQQ();
        huobi.onlineService.positionQQ();
        return false;
    });
    $('.online-service-inner a').click(function() {
        $(this).parent().addClass('hidden');
    });
    $('.goto-top').click(function() {
        $('body,html').animate({
            scrollTop: -$(this).offset().top
        });
    });
});

//隐藏底部行情
function hideHangQingInner() {
    $('.hangqing-inner').animate({
        'height': 0
    },
    function() {
        $('.hangqing-fixed-mask').animate({
            opacity: 0
        },
        function() {
            $(this).removeClass('show');
            $('.hangqing-inner .market_flash').html('');
        })
    });
}

function set_hidden_trade_alert_cookie() {
    var date = new Date();
    var expireDays = 10;
    date.setTime(date.getTime() + expireDays * 24 * 3600 * 1000);
    document.cookie = "_hidden_trade_alert=1;expires=" + date.toGMTString() + ";path=/;domain=.huobi.com";
}

jQuery(document).ready(function() {
    //价格区块
    var pathname = window.location.pathname;
    var search = request('a');
    if (search != '') {
        var href = pathname + "?a=" + search;
    } else {
        var href = pathname;
    }
    switch (href) {
    case '/':
    case '/index.php':
    case '/trade/index.php':
    case '/trade/':
        servicepriceblock();
        int_refresh = setInterval(function() {
            servicepriceblock();
        },
        10000);
        break;
    default:
        break;
    }

});
jQuery(document).ready(function() {
    //更新当前用户余额
    btc_trade_amount_balance();
    int_refresh = setInterval(function() {
        btc_trade_amount_balance();
    },
    15000);
});

jQuery(document).ready(function() {
    reload_captcha();
    $("#captcha_img").click(function() {
        reload_captcha();
    });
    setInterval(function() {
        reload_captcha();
    },
    1000 * 60 * 4);
});